package com.wf.day_0619.test3.cglib;

import com.wf.day_0619.test3.CalculatorServiceImpl;
import net.sf.cglib.proxy.Enhancer;

/**
 * @author mpk
 * @since 2024/6/19 19:04:20
 */
public class Demo {
    public static void main(String[] args) {

        Enhancer enhancer = new Enhancer();

        enhancer.setSuperclass(CalculatorServiceImpl.class);

        enhancer.setCallback(new MyMethodInterceptor());


        CalculatorServiceImpl calculatorService = (CalculatorServiceImpl)enhancer.create();

        System.out.println(calculatorService.add(1, 2));
        System.out.println(calculatorService.sub(1, 2));
        System.out.println(calculatorService.mul(1, 2));
        System.out.println(calculatorService.div(1, 2));


    }


}
